#include<bits/stdc++.h>
using namespace std;
int T,n,m,l,v;
int a[100009],d[100009],u[100009],p[100009];
int ll[100009],r[100009];
bool big_pd,small_pd,mid_pd,pdf;
int i,j;
vector<int> _s;
bool pd_(){
    pdf=0;
    for(i=1;i<=n;i++){
        pdf=0;
        if(ll[i]==1e9+7&&r[i]==-1e9+7)continue;
        for(j=ll[i];j<=r[i];j++){
            if(_s[j-1]==1){
                pdf=1;
                break;
            }
        }
        if(!pdf)return 0;
    }
    return 1;
}
int __ans;
int dfs(int num,int sum){
    if(num==m){
        if(pd_())return sum;
        return 0;
    }
    _s.push_back(0);
    __ans=dfs(num+1,sum);
    _s.pop_back();
    _s.push_back(1);
    __ans=max(__ans,dfs(num+1,sum+1));
    _s.pop_back();
    return __ans;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--){
        cin>>n>>m>>l>>v;
        big_pd=small_pd=mid_pd=0;
        for(i=1;i<=n;i++){
            cin>>d[i]>>u[i]>>a[i];
            if(a[i]<0)small_pd=1;
            else if(a[i]==0)mid_pd=1;
            else big_pd=1;
        }
        for(i=1;i<=m;i++)cin>>p[i];
        int ans=0;
        if(mid_pd&&!small_pd&&!big_pd){
            for(i=1;i<=n;i++){
                if(u[i]>v&&p[m]>=d[i])ans++;
            }
            cout<<ans<<" "<<m-1<<"\n";
        }else if(big_pd&&!mid_pd&&!small_pd){
            for(i=1;i<=n;i++){
                if(p[m]<d[i])continue;
                int k=v*v;
                int f=p[m]-d[i];
                int speed=u[i]*u[i]+2*a[i]*f;
                if(speed>k)ans++;
            }
            cout<<ans<<" "<<m-1<<"\n";
        }else if(big_pd&&mid_pd&&!small_pd){
            for(i=1;i<=n;i++){
                if(p[m]<d[i])continue;
                int k=v*v;
                int f=p[m]-d[i];
                int speed=u[i]*u[i]+2*a[i]*f;
                if(speed>k)ans++;
            }
            cout<<ans<<" "<<m-1<<"\n";
        }else{
            for(i=1;i<=n;i++){
                ll[i]=1e9+7,r[i]=-1e9+7;
                for(j=1;j<=m;++j){
                    if(p[j]<d[i])continue;
                    int k=v*v;
                    int f=p[j]-d[i];
                    int speed=max(u[i]*u[i]+2*a[i]*f,0);
                    if(speed>k){
                        ll[i]=min(ll[i],j);
                        r[i]=max(r[i],j);
                    }
                }
                if(ll[i]!=1e9+7||r[i]!=-1e9+7)ans++;
            }
            _s.clear();
            cout<<ans<<" "<<m-dfs(0,0)<<"\n";
        }
    }
    return 0;
}
